package com.itheima.spring_mvc_xml.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloController implements Controller {

    //请求来后自动执行的方法，类似于Servlet时代的doService
    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView mv = new ModelAndView();

        //封装数据准备向视图传递
        mv.addObject("msg","springmvc第一个程序！");
        //配置视图名称为hello
        mv.setViewName("hello");
        return mv;
    }
}